import request from '@/utils/request'
/**
 *
 * @param {*} mobile
 * @param {*} code
 * @returns
 */
export const loginAPI = (mobile, code) => {
  return request({
    url: '/v1_0/authorizations',
    method: 'POST',
    data: {
      mobile,
      code
    }
  })
}

export const getCodeAPI = (mobile) => {
  return request({
    url: `/v1_0/sms/codes/${mobile}`
  })
}

export const getUserAPI = () => {
  return request({
    url: '/v1_0/user'
  })
}

export const getUserInfoAPI = () => {
  return request({
    url: '/v1_0/user/profile'
  })
}
export const setUserInfoAPI = (data) => {
  return request({
    url: '/v1_0/user/profile',
    method: 'PATCH',
    data
  })
}
/**
 * FormData 指定表单数据
 * @param {*} file 图片类型
 * @returns Promise
 */
export const uploadPhotoAPI = (file) => {
  const fm = new FormData()
  fm.append('photo', file)
  return request({
    url: '/v1_0/user/photo',
    method: 'PATCH',
    data: fm
  })
}
//关注用户
export const guanzhuAPI = (target) => {
  return request({
    method: 'POST',
    url: '/v1_0/user/followings',
    data: {
      target
    }
  })
}
//取消关注
export const notguanzhuAPI = (target) => {
  return request({
    method: 'DELETE',
    url: `/v1_0/user/followings/${target}`
  })
}